<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<sql:query var="rs" dataSource="jdbc/j2db">
	select * 
	from leavedata, shift, leaves
	where leavedata.shift_number = shift.shift_number
	and leaves.leave_number = leavedata.leave_number
	and leavedata.approved = '0'
	and shift.user_id = ?
	<sql:param>${member.user_id}</sql:param>
</sql:query>
<sql:query var="rs2" dataSource="jdbc/j2db">
	SELECT *
	FROM shift s, overtimedata od, users us, overtimes ot
	WHERE s.user_id = us.user_id
	AND s.shift_number = od.shift_number
	AND od.ot_number = ot.ot_number
	and od.approved = '0'
	and s.user_id = ?
	<sql:param>${member.user_id}</sql:param>
</sql:query>
<c:forEach var="r" items="${rs.rows }">
<c:set var="leaved_number" value="${r.leaved_number }" />
<c:set var="leaved_date" value="${r.leaved_date }" />
<c:set var="leave_name" value="${r.leave_name }" />
<c:set var="approved" value="${r.check }" />
<c:set var="check_id" value="${r.checker_id }" />
<c:set var="leaved_time" value="${r.leaved_time }" />
</c:forEach>
<c:forEach var="r2" items="${rs2.rows}">
<c:set var="otd_number" value="${r2.otd_number }" />
<c:set var="otd_date" value="${r2.otd_date }" />
<c:set var="ot_name" value="${r2.ot_name }" />
<c:set var="approved" value="${r2.check }" />
<c:set var="checker_id" value="${r2.checker_id }" />
<c:set var="otd_time" value="${r2.otd_time }" />
</c:forEach>

<h1>最新消息</h1>
<br><br>
<br><br>
<h3>員工編號：${member.user_id}</h3><br>
<c:if test="${leaved_number != null }">
<h1>申請請假項目：</h1>
<table border=1 align="center">
<tr>
<th>請假編號</th>
<th>請假日期</th>
<th>請假別</th>
<th>是否核准</th>
<th>核准主管</th>
<th>申請時間</th>
</tr>
<tr>
<td>${leaved_number }</td>
<td>${leaved_date }</td>
<td>${leave_name }</td>
<td>
<c:choose>
<c:when test="${approved == 0}">
未核准
</c:when>
<c:otherwise>
已核准
</c:otherwise>
</c:choose>
</td>
<td>${checker_id }</td>
<td>${leaved_time }</td>
</tr>
</table>
</c:if>

<br><br>
<c:if test="${otd_number != null }">

<h1>申請加班項目：</h1>
<table border=1 align="center">
<tr>
<th>加班編號</th>
<th>加班日期</th>
<th>加班別</th>
<th>是否核准</th>
<th>核准主管</th>
<th>申請時間</th>
</tr>
<tr>
<td>${otd_number }</td>
<td>${otd_date }</td>
<td>${ot_name }</td>
<td>

<c:choose>
<c:when test="${approved == 0}">
未核准
</c:when>
<c:otherwise>
已核准
</c:otherwise>
</c:choose>

</td>
<td>${checker_id }</td>
<td>${otd_time }</td>
</tr>
</table>
</c:if>